package cn.le.service;

import cn.le.dao.UserDAO;
import cn.le.entty.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserDAO userDAO;

    public static int listSize = 0;
    public static int saveSize = 0;

    @Transactional
    public void bachInsert(@Param("list") List<User> list) {
        Integer saveIndex  = userDAO.bachInsert(list);
        set(list.size(),saveIndex);
    }

    public synchronized void set(int listSize,int saveSize){
        UserService.listSize += listSize;
        UserService.saveSize += saveSize;
    }

}
